home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1997 #3
/
Amiga Plus CD - 1997 - No. 03.iso
/
pd
/
programmierung
/
alienbreed3d2_src
/
amos
/
256texture.amos
/
256texture.amosSourceCode
Wrap
AMOS Source Code
|
1997-01-31
|
4KB
|
172 lines
Set Buffer 20
Screen Open 7,640,24,2,Hires : Wait Vbl : Curs Off : Flash Off : Extension_12_0380 -1
Palette $8,$FF0 : Paper 0 : Pen 1 : Ink 1 : Box 0,4 To 639,20 : Wait Vbl
Screen Display 7,,Y Hard(7,72),,
Reserve As Work 15,65536*2
Trap Bload "ab3:includes/256pal",Start(15)
If Errtrap
Screen To Front 7 : Screen 7
Locate 1,1 : Print Space$(78)
Locate 1,1 : Centre "Unable to load 'ab3:includes/256pal'"
Wait Key
Edit
End If
Dim R(255),G(255),B(255),CO(63),GLARE(31)
Dim PR(31),PG(31),PB(31)
S=Start(15)
For A=0 To 255
R(A)=Deek(S) : Add S,2
G(A)=Deek(S) : Add S,2
B(A)=Deek(S) : Add S,2
Next
Reserve As Work 14,100000
For A=1 To 32
M$="ab3:graphics/textures/glare."+Str$(A)-" "
If Exist(M$)
GLARE(A-1)=1
Trap Load Iff M$,0
If Errtrap
Screen To Front 7 : Screen 7
Locate 1,1 : Print Space$(78)
Locate 1,1 : Centre "Unable to load '"+M$+"'"
Wait Key
Edit
End If
Else
GLARE(A-1)=0
M$="ab3:graphics/textures/texture."+Str$(A)-" "
Trap Load Iff M$,0
If Errtrap
Screen To Front 7 : Screen 7
Locate 1,1 : Print Space$(78)
Locate 1,1 : Centre "Unable to load '"+M$+"'"
Wait Key
Edit
End If
End If
Trap Bload M$,Start(14)
If Errtrap
Screen To Front 7 : Screen 7
Locate 1,1 : Print Space$(78)
Locate 1,1 : Centre "Unable to load '"+M$+"'"
Wait Key
Edit
End If
S=Hunt(Start(14) To Start(14)+10000,"CMAP")+8
For B=0 To 31
PR=Peek(S) : Add S,1
PG=Peek(S) : Add S,1
PB=Peek(S) : Add S,1
' PR(B+32)=PR(B)/2
' PG(B+32)=PG(B)/2
' PB(B+32)=PB(B)/2
PR(B)=PR
PG(B)=PG
PB(B)=PB
Next
If GLARE(A-1)=0
Screen To Front 7 : Screen 7
Locate 1,1 : Print Space$(78)
Locate 1,1 : Centre "Grabbing colours"
For B=0 To 31
ND=100000000 : T=0
For Z=0 To 255
D=Abs(R(Z)-PR(B))+Abs(G(Z)-PG(B))+Abs(B(Z)-PB(B))
If D<ND
ND=D : T=Z
End If
If D=0
Z=255
End If
Next
CO(B)=T
Next
Else
For B=0 To 31 : CO(B)=B : Next
End If
B=A-1
S=Start(15)+(B mod 4)+((B/4) and 3)*256+(B/16)*65536
Screen To Front 7 : Screen 7
Locate 1,1 : Print Space$(78)
Locate 1,1 : Centre "Grabbing Texture "+(Str$(A)-" ")+"/32"
Screen 0
For X=0 To 63 : For Y=0 To 63
Poke S+X*4+Y*1024,CO( Extension_12_044C(X,Y))
Extension_12_036E X,Y,0
Next : Next
Next
F$=Fsel$("ab3:includes/","newtexturemaps","Select a save name for the datafile:")
Trap Bsave F$,Start(15) To Start(15)+(65536*2)
If Errtrap
Screen To Front 7 : Screen 7
Locate 1,1 : Print Space$(78)
F$="Unable to save "+F$
Locate 1,1 : Centre F$
Wait Key
Edit
End If
'N=Start(14)
'For A=32 To 1 Step -1
' For QB=0 To 255
'
' R=(R(QB)*A)/32
' G=(G(QB)*A)/32
' B=(B(QB)*A)/32
'
' ND=100000000 : T=0
' For Z=0 To 255
' D=Abs(R(Z)-R)+Abs(G(Z)-G)+Abs(B(Z)-B)
' If D<ND
' ND=D : T=Z
' End If
' If D=0
' Z=255
' End If
' Next
'
' Poke N,T : Add N,1
'
' Next
'Next
'For A=32 To 1 Step -1
' For QB=0 To 255
'
' If A>=16
' V=A-16
' R=R(QB)+((255-R(QB))*V)/16
' G=G(QB)+((255-G(QB))*V)/16
' B=B(QB)+((255-B(QB))*V)/16
' Else
' R=(R(QB)*A)/16
' G=(G(QB)*A)/16
' B=(B(QB)*A)/16
' End If
'
' ND=100000000 : T=0
' For Z=0 To 255
' D=Abs(R(Z)-R)+Abs(G(Z)-G)+Abs(B(Z)-B)
' If D<ND Then ND=D : T=Z
' If D=0 Then Z=255
' Next
'
' Poke N,T : Add N,1
'
' Next
'Next
'Bsave "ab3:includes/newtexturemaps.pal",Start(14) To N